import django_filters
from .models import Province


class ProvinceFilter(django_filters.rest_framework.FilterSet):
    """
    过滤
    """
    product = django_filters.NumberFilter(method="product_filter", field_name="product")

    def product_filter(self, queryset, name, value):
        queryset = queryset.filter(productcityrelation__product_id=value)
        return queryset

    class Meta:
        model = Province
        fields = ["product"]
